package com.digital.smartgrow.service.title;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.AcademicExchangeMapper;
import com.digital.smartgrow.dto.title.AcademicExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class AcademicExchangeServiceImpl implements AcademicExchangeService{

    @Autowired
    AcademicExchangeMapper academicExchangeMapper;


    @Override
    @Transactional
    public List<AcademicExchange> findList(AcademicExchange academicExchange) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard",academicExchange.getIdcard());
        queryWrapper.eq("status", 0);
        return academicExchangeMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void deleteCommend(AcademicExchange academicExchange) {
        AcademicExchange academicExchange1 = new AcademicExchange();
        Date date = new Date();
        academicExchange1.setStatus(1).setId(academicExchange.getId()).setTime(date);
        academicExchangeMapper.updateById(academicExchange1);
    }
}
